<template>
	<view>
		<view class="content">
			<view v-if="checkboxList.length>0">
				<u-radio-group @change="checkboxGroupChange" :width="radioCheckWidth" :wrap="radioCheckWrap">
					<view class="list" v-for="(item, index) in checkboxList" :key="index">
						<!-- <u-checkbox activeColor="#FFC31E" shape="circle" class="checkbox" v-model="item.checked" :name="item.uid"></u-checkbox> -->
						<u-radio shape="circle" activeColor="#FFC31E" class="checkbox" v-model="item.checked" :name="item.uid"></u-radio>
						<view class="head">
							<image :src="getHead(item.head_image)" mode=""></image>
						</view>
						<view class="user">
							<view class="name">
								{{item.username}}
							</view>
							<view class="">
								{{item.tel}}
							</view>
						</view>
					</view>
				</u-radio-group>
			</view>
			<view class="none" v-else>
				<view class="none-view">
					<image src="../../../static/image/none.png" class="none-image"></image>
					<view class="none-name">
						暂无符合可邀请条件的好友~
					</view>
				</view>
			</view>

			<view class="div"></view>
			<view class="bottom">
				<button @click="sureInvite">确认邀请</button>
			</view>
		</view>
	</view>
</template>

<script>
	var than;
	export default {
		data() {
			return {
				radioCheckWidth: 'auto',
				radioCheckWrap: false,
				checkboxList: [],
				likeFruit: ''
			}
		},
		onLoad(option) {
			than = this;
			than.post('api/groupwork_small/familyList', null, function(data) {
				for (let i in data) {
					data[i].checked = false
					data[i].disabled = false
				}
				than.checkboxList = data;
			})
		},
		methods: {
			// checkbox选择发生变化
			checkboxGroupChange(e) {
				this.likeFruit = e;
			},
			go() {
				uni.redirectTo({
					url: 'group'
				})
			},
			sureInvite() {
				than.post('api/groupwork_small/sureInvite', {
					uid: this.likeFruit
				}, function(data) {
					than.toast(data);
					setTimeout(function() {
						uni.navigateBack()
					}, 1500);
				})
			}
		}
	}
</script>

<style lang="less">
	.div {
		height: 100rpx;
	}

	.bottom {
		position: fixed;
		width: 100%;
		height: 100rpx;
		bottom: 0;

		button {
			width: 314rpx;
			height: 80rpx;
			background: linear-gradient(0deg, #FBDE80, #FDEBA1);
			line-height: 80rpx;
			box-shadow: 0px 6rpx 8rpx 0px rgba(170, 170, 170, 0.16);
			border-radius: 40rpx;
			font-size: 32rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #835529;
		}
	}

	.content {
		.list {
			display: flex;
			align-items: center;
			height: 135rpx;
			width: 100%;

			.checkbox {
				margin-left: 60rpx;
			}

			.head {
				margin-right: 12rpx;

				image {
					width: 99rpx;
					height: 99rpx;
					border-radius: 50%;
				}
			}

			.user {
				.name {
					margin-bottom: 15rpx;
					font-size: 30rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #333333;
				}

				.text {
					font-size: 24rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #999999;
				}
			}
		}
	}
</style>
